package com.google.gson;

import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;

import java.io.*;

/**
 * Converts Java objects to and from JSON.
 *
 */
public abstract class TypeAdapter<T> {

    public TypeAdapter() {
    }

    /**
     * Writes one JSON value (an array, object, string, number, boolean or null)
     * for {@code value}.
     *
     * @param value the Java object to write. May be null.
     */
    public abstract void write(JsonWriter out, T value) throws IOException;


    /**
     * Reads one JSON value (an array, object, string, number, boolean or null)
     * and converts it to a Java object. Returns the converted object.
     *
     * @return the converted Java object. May be null.
     */
    public abstract T read(JsonReader in) throws IOException;

}
